extends Node

@onready var nameInput = $"../name"
@onready var welcome = $"../welcome"

# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass


func _on_save_pressed():
	var config = ConfigFile.new()
	config.set_value("Player1", "player_name", nameInput.text)
	config.save("user://player.cfg")


func _on_read_pressed():
	var config = ConfigFile.new()
	var err = config.load("user://player.cfg")
	if err != OK:
		print(err)
	for player in config.get_sections():
		var player_name = config.get_value(player, "player_name")
		welcome.text = "Welcome " + player_name
		
